
/*
*
* 使用类和对象来实现交换函数
* */
class MyValue{
    public int a;
}
public class Test2 {


    public static void swap(MyValue myValue1,MyValue myValue2) {
        int tmp = myValue1.a;
        myValue1.a = myValue2.a;
        myValue2.a = tmp;

    }
    public static void main(String[] args) {
        MyValue myValue1 = new MyValue();
        MyValue myValue2 = new MyValue();
        myValue1.a = 10;
        myValue2.a = 20;
        System.out.println(myValue1.a + " " +  myValue2.a);
        swap(myValue1,myValue2);
        System.out.println(myValue1.a + " " +  myValue2.a);

    }
}
